<?php

/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/


Route::group(['prefix'=>'Admin','namespace'=>'Admin'],function(){
	Route::get('/reg','RegisterController@showRegistrationForm')->name('reg');//注册视图
	Route::post('/reg','RegisterController@register');//注册处理

	Route::get('/login','LoginController@showLoginForm')->name('login');//登录视图
	Route::post('/login','LoginController@login');//登入处理
	Route::get('/logout', 'LoginController@logout')->name('logout');//登出

	Route::get('/index','IndexController@index');//后台首页

	// 用户管理
	Route::get('/User/list','UserController@index');//用户列表
	Route::match(['get','post'],'/User/add','UserController@add');//用户添加
	Route::match(['get','post'],'/User/edit/{id}','UserController@edit');//用户修改
	Route::get('/User/del/{id}','UserController@del');//用户删除

	// 角色管理
	Route::get('/Roles/list','RolesController@index');
	Route::match(['get','post'],'/Roles/add','RolesController@add');
	Route::match(['get','post'],'/Roles/edit/{id}','RolesController@edit');
	Route::get('/Roles/del/{id}','RolesController@del');

	// 栏目管理
	Route::get('/Category/list/{id?}','CategoryController@index');
	Route::match(['get','post'],'/Category/add/{id?}','CategoryController@add');
	Route::match(['get','post'],'/Category/edit/{id}','CategoryController@edit');
	Route::get('/Category/del/{id}','CategoryController@del');

	// 书籍管理
	Route::get('/Books/list','BooksController@index');
	Route::match(['get','post'],'/Books/add','BooksController@add');
	Route::match(['get','post'],'/Books/edit/{id}','BooksController@edit');
	Route::get('/Books/del/{id}','BooksController@del');

});


// 首页路由
Route::group(['namespace'=>'\Home\Index'],function(){
	Route::get('/','IndexController@index');
});

// 小说类目路由
//Route::group(['namespace'=>'\Home\Categroy'],function(){
//	Route::get('/Categroy','CategroyController@index');
//});


/** 
 * 教师后台页面  如果出现errors未定义 ,可以使用'middleware'=>['web'] 使用中间件web 	
 * 是因为error从全局移到了web中
**/

Route::group(['prefix'=>'Teacher','namespace'=>'\Teacher'],function(){

	// 教师的路由
	Route::get('/reg','RegisterController@showRegistrationForm')->name('teacherReg');//注册视图
	Route::post('/reg','RegisterController@register');//注册处理
	Route::get('/login','LoginController@showLoginForm')->name('login');//登录视图
	Route::post('/login','LoginController@login');//登入处理
	Route::get('/logout', 'LoginController@logout')->name('logout');//登出

	Route::get('/index','IndexController@index');

	// 问题添加  资源控制器 功能 资源路由
	//Route::resource('questions','QuestionsController',['only'=>['index','add','edit']]);
	Route::get('/questions/list','QuestionsController@index');
	Route::match(['get','post'],'/questions/add','QuestionsController@add');
	Route::match(['get','post'],'/questions/edit/{id}','QuestionsController@edit');
	Route::match(['get','post'],'/questions/del/{id}','QuestionsController@del');

	// 材料
	Route::get('/material/list','MaterialController@getMaterial');
	Route::match(['get','post'],'/material/add','MaterialController@add');
	Route::match(['get','post'],'/material/edit/{id}','MaterialController@edit');
	Route::match(['get','post'],'/material/del/{id}','MaterialController@del');
	Route::post('/material/bind/{id}','MaterialController@binds');
	Route::post('material/del_question','MaterialController@del_question');
});

//Route::get('/api/{book}','Api\NovelController@index');
//Route::get('/cat','Api\NovelController@cat');
Route::get('/home', 'HomeController@index')->name('home');
Route::get('/questions', 'TeacherApi\Question\QuestionListController@getQuestions');
